package edu.stthomas.seis752.dao;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import edu.stthomas.seis752.model.Location;

@Repository
public class LocationDaoImpl implements LocationDao {

	@PersistenceContext
	private EntityManager manager;
	
	@Override
	public List<Location> getLocations(int number) {
		Query  query = manager.createQuery("FROM Location");
		query.setMaxResults(number);
		List<Location> result = query.getResultList();
		return result;
	}

	@Override
	public Location getLocation(Long id) {
		return manager.find(Location.class, id);
	}

}
